<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php 
	$ci = &get_instance();
	$currency = currencyDataConfig();
	$id= intval( $this->input->post('user_id', TRUE) );
	if($id){
		$USER = clone_($ci->user_entity->init('id',$id));
		if($USER->getUserRefferId()){
			$U = clone_($ci->user_entity->init('id',$USER->getUserRefferId()));
		}	
	}	
?>
<form action="<?php echo site_url('admin/dataman/user/edit_submit');?>" name="edit_submit" id="edit_submit" method="post" enctype="multipart/form-data" >
<?php if($id):?>
	<?php if(isset($U)):?>
		<div class="grid2"><span class="bold">Referred User:</span></div>
		<div class="grid6"><?php echo $U->getUserName();?></div>
	<?php endif;?>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Username:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="username" name="username" value="<?php echo $USER->getUserName();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="username_error">Required field (Username can not duplicated).</span></div>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Email:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="email" name="email" value="<?php echo $USER->getEmail();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="email_error">Required field (Email can not duplicated).</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Password:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="password" name="password" value="<?php echo $USER->getPasswd();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="password_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Full name:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="fullname" name="fullname" value="<?php echo $USER->getFullName();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="fullname_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Mobile:</span></div>
	<div class="grid6"><input type="text" maxlength="15" id="mobile" name="mobile" value="<?php echo $USER->getMobile();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="mobile_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Country:</span></div>
	<div class="grid6"><?php echo form_dropdown( 'country',
								$options = countriesOnTheWorldDataConfig(),
								$selected = array($USER->getCountry()),
								"id='country'"
							);	?></div>
	<div class="grid2"><span class="bold red hidden" id="country_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">State:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="state" name="state" value="<?php echo $USER->getState();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="state_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">City:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="city" name="city" value="<?php echo $USER->getCity();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="city_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Cash:</span></div>
	<div class="grid4">
		<input type="text" maxlength="45" id="cash" name="cash" value="<?php echo $USER->getCash();?>" class="std-input"/>
		<?php echo $currency[$USER->getCurrencyCode()];?>
	</div>
	<div class="grid2"><span class="bold red hidden" id="cash_error">Not valid field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Coin:</span></div>
	<div class="grid4">
		<input type="text" maxlength="45" id="coin" name="coin" value="<?php echo $USER->getCoin();?>" class="std-input"/>
	</div>
	<div class="grid2"><span class="bold red hidden" id="coin_error">Not valid field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Bonus:</span></div>
	<div class="grid4">
		<input type="text" maxlength="45" id="bonus" name="bonus" value="<?php echo $USER->getBonus();?>" class="std-input"/>
	</div>
	<div class="grid2"><span class="bold red hidden" id="bonus_error">Not valid field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Avatar:</span></div>
	<div class="grid4"><?php echo form_upload('avatar');?></div>
	<div class="grid2"><?php echo thumb($USER->getMyAvatar(),60,60);?></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Created Date:</span></div>
	<div class="grid6"><?php echo sysDateFormat($USER->getCreatedTime());?></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Refferal Code:</span></div>
	<div class="grid6"><?php echo ($USER->getReferralCode());?></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Currency Code:</span></div>
	<div class="grid6"><?php echo $currency[$USER->getCurrencyCode()];?></div>
	
	<?php echo form_hidden( "user_id", $id ); ?>
	
	<div class="clrboth"></div>
	<div class="grid2">&nbsp;</div>
	<div class="grid6"><input type="submit" class="button" /> <?php echo loader_image('id="loader_image" class="hidden"');?></div>
	<div class="grid2"><span class="bold red hidden" id="submit_error">Missing registration.</span></div>	
	
	<div class="clrboth"></div>	
<?php else : ?>
	
	<div class="grid2"><span class="bold">*Username:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="username" name="username" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="username_error">Required field (Username can not duplicated).</span></div>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Email:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="email" name="email" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="email_error">Required field (Email can not duplicated).</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Password:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="password" name="password" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="password_error">Required field.</span></div>
	
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Full name:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="fullname" name="fullname" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="fullname_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Mobile:</span></div>
	<div class="grid6"><input type="text" maxlength="15" id="mobile" name="mobile" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="mobile_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Country:</span></div>
	<div class="grid6"><?php echo form_dropdown( 'country',
								$options = countriesOnTheWorldDataConfig(),
								$selected = array(),
								"id='country'"
							);	?></div>
	<div class="grid2"><span class="bold red hidden" id="country_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">State:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="state" name="state" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="state_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">City:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="city" name="city" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="city_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Cash:</span></div>
	<div class="grid4">
		<input type="text" maxlength="45" id="cash" name="cash" value="0" class="std-input"/>
	</div>
	<div class="grid2"><span class="bold red hidden" id="cash_error">Not valid field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Coin:</span></div>
	<div class="grid4">
		<input type="text" maxlength="45" id="coin" name="coin" value="0" class="std-input"/>
	</div>
	<div class="grid2"><span class="bold red hidden" id="coin_error">Not valid field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Bonus:</span></div>
	<div class="grid4">
		<input type="text" maxlength="45" id="bonus" name="bonus" value="0" class="std-input"/>
	</div>
	<div class="grid2"><span class="bold red hidden" id="bonus_error">Not valid field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Avatar:</span></div>
	<div class="grid4"><?php echo form_upload('avatar');?></div>
	
	<div class="clrboth"></div>
	<div class="grid2">&nbsp;</div>
	<div class="grid6"><input type="submit" class="button" /> <?php echo loader_image('id="loader_image" class="hidden"');?></div>
	<div class="grid2"><span class="bold red hidden" id="submit_error">Missing registration.</span></div>	
	
	<div class="clrboth"></div>	
<?php endif;?>	
</form>
